package com.example.truthordare;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class PlaygameAdapter extends BaseAdapter {
	private Context context;
	private static final String TAG = NameAdapter.class.getSimpleName();
	ArrayList<Tempplaygame> listArray;

	public PlaygameAdapter(Context context, ArrayList<Tempplaygame> listArray) {
		super();
		this.context = context;
		this.listArray = listArray;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listArray.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (view == null) {
			LayoutInflater inflater = LayoutInflater.from(parent.getContext());
			view = inflater.inflate(R.layout.gameplayer, parent, false);
		}
		final Tempplaygame tempplaygames = listArray.get(position);
		TextView tvname = (TextView) view.findViewById(R.id.player_name);
		TextView tvscore = (TextView) view.findViewById(R.id.player_score);
		tvname.setText(tempplaygames.getPlayer());
		tvscore.setText(""+tempplaygames.getSroce());
		
		return view;
	}

}
